package com.web.sys.controller;

import java.util.List;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.web.sys.model.SysSource;
import com.web.sys.sercice.ISysSourceService;
import com.web.sys.sercice.ISysUserService;
import com.web.sys.util.ContextUtil;

@Controller
@RequestMapping("/index")
public class IndexController {
	
	@Inject
	private ISysSourceService sysSourceService;
	@Inject
	private ISysUserService sysUserService;
	
	@ResponseBody
	@RequestMapping(value={"/queryNavigation"},method=RequestMethod.GET)
	public List<SysSource> queryNavigation(HttpServletRequest req,HttpServletResponse resp,HttpSession session){
		String username=ContextUtil.getUserName();
		String role=sysUserService.queryUserRole(username);
		List<SysSource> nav=sysSourceService.queryAllNavigationByRole(role);
		//List<SysSource> nav=sysSourceService.queryAllNavigation();
		return nav;
	}
	@ResponseBody
	@RequestMapping(value={"/querySourceList"},method=RequestMethod.POST)
	public List<SysSource> querySourceList(HttpServletRequest req,HttpServletResponse resp,HttpSession session){
		String text=req.getParameter("text");
		List<SysSource> nav=sysSourceService.queryAllSource(text);
		return nav;
	}
	
	@RequestMapping(value="/xt/yh",method=RequestMethod.GET)
	public String toSysUserManagerPage(){
		return "/user/yh";
	}
	/*@RequestMapping(value="/xt/create",method=RequestMethod.GET)
	public String toSysUserCreatePage(){
		return "/user/create";
	}*/
}
